#include <string>
#include <iostream>
using namespace std;
class Solution
{
public:
    bool validPalindrome(string s, int count)
    {
        if (count > 1)
        {
            return false;
        }
        int l = 0, r = s.size() - 1;
        while (l <= r)
        {
            if (s[l] != s[r])
            {
                count++;
                return validPalindrome(s.substr(l, r - l), count) || validPalindrome(s.substr(l + 1, r - l), count);
            }
            else
            {
                l++;
                r--;
            }
        }
        return count < 2;
    }
    bool validPalindrome(string s)
    {
        int l = 0, r = s.size() - 1;
        int count = 0;
        while (l <= r)
        {
            if (s[l] != s[r])
            {
                count++;
                return validPalindrome(s.substr(l, r - l), count) || validPalindrome(s.substr(l + 1, r - l), count);
            }
            else
            {
                l++;
                r--;
            }
        }
        return count < 2;
    }
};
int main(int argc, char const *argv[])
{

    string s = "aydmda";
    Solution ss;
    cout << ss.validPalindrome(s);
    return 0;
}
